package cn.cyb.server.common.utils;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

import java.io.IOException;

/**
 * @author Administrator
 * @date 2025/1/12 0012
 */
public class HttpUtils {

    public static String sendGet(String url, String param) throws IOException {
        OkHttpClient client = new OkHttpClient.Builder().build();
        if (StringUtils.isNotEmpty(param)) {
            url += "?" + param;
        }
        Request request = new Request.Builder().url(url).build();
        Response response = client.newCall(request).execute();

        String str = null;
        if (response.isSuccessful()) {
            ResponseBody body = response.body();
            str = body.string();
            body.close();
        }
        return str;
    }
}
